package homework.api02.homework_api01;

public class ObjectDemo {
    public static void main(String[] args) {
        Point p = new Point(100,200);
        System.out.println(p);//homework.api02.homework_api01.Point@4554617c
        System.out.println(p.toString());//homework.api02.homework_api01.Point@4554617c

        //java中任何类型与字符串的连接结果都是字符串
        //实际上JVM也是调用该类的toString()方法将其转换为字符串了
        String str = "这是一个点:"+p;
        System.out.println(str);

        //equals
        String s1 = new String("hello");
        String s2 = new String("hello");
        System.out.println(s1.equals(s2));//true

        StringBuilder builder1 = new StringBuilder("hello");
        StringBuilder builder2 = new StringBuilder("hello");
        System.out.println(builder1.equals(builder2));//false

        //类型不同,所以一定为false
        System.out.println(s1.equals(builder1));

        Point p1 = new Point(100, 200);
        Point p2 = new Point(100,200);
        System.out.println(p1==p2);//false
        System.out.println(p1.equals(p2));//true
    }
}
